//
//  DeviceInfoViewController.m
//  WifiApp
//
//  Created by liao Echo on 14-11-3.
//  Copyright (c) 2014年 Echo. All rights reserved.
//

#import "DeviceInfoViewController.h"
#import "DevDetailViewController.h"
#import "PokerControlClient.h"
#import "DataManager.h"

@interface DeviceInfoViewController (){
    BOOL fasda;
    
    NSString *savetext;
}

@end

@implementation DeviceInfoViewController
@synthesize version_;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)setnIntLabel:(UILabel*)label string:(NSString*)nextstr{
    //    nextstr = @"0419330000";
    unsigned int tempf;
    NSString *mutString = [nextstr substringFromIndex:2];
    NSString *str1 = [mutString substringFromIndex:4];
    NSString *str2 = [mutString substringToIndex:4];
    NSString *string1 = [NSString stringWithFormat:@"%@%@", str1, str2];
    NSScanner *scanner = [NSScanner scannerWithString:string1];
    [scanner scanHexInt: &tempf];
    label.text = [NSString stringWithFormat:@"%d", tempf];
}
-(void)setLabel:(UILabel*)label string:(NSString*)nextstr{
    unsigned tempi;
    NSString *mutString = [nextstr substringFromIndex:2];
    NSString *str1 = [mutString substringFromIndex:4];
    NSString *str2 = [mutString substringToIndex:4];
    NSString *string1 = [NSString stringWithFormat:@"%@%@", str1, str2];
    NSScanner *scanner = [NSScanner scannerWithString:string1];
    [scanner scanHexInt:&tempi];
    float *tempf = (float *)&tempi;
    label.text = [NSString stringWithFormat:@"%.2f", *tempf];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [NC addObserver:self selector:@selector(app_management:) name:NOTI_app_all_management_INFO object:nil];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [NC removeObserver:self];
}
-(void)app_management:(NSNotification*)noti{
    
    if (noti.object) {//管理信息
        
        UILabel *labelxx = [[UILabel alloc] initWithFrame:CGRectMake(135, 0, SCREEN_WIDTH-135-10, 0)];
        [self.view addSubview:labelxx];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(135, 0, SCREEN_WIDTH-135-10, 0)];
        [self.view addSubview:label];
        
        NSString *string = noti.object;
        NSRange range = [string rangeOfString:@"unit=\""];
        if (range.location != NSNotFound) {
            
            if (!savetext) {
                savetext = [[NSString alloc] init];
            }
            
            labelxx.text = @"单位:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"unit=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            }
            
            labelxx.text = @"部门:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"department=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            }
            
            labelxx.text = @"负责人:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"head=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            
            labelxx.text = @"位号:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"item=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            }
            
            labelxx.text = @"序列号:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"serinum=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            }
            
            labelxx.text = @"备注:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"note=\""];
                if (range.location != NSNotFound) {
                    NSString *nextstr = [string substringFromIndex:range.location+range.length];
                    NSRange range1 = [nextstr rangeOfString:@"\""];
                    nextstr = [nextstr substringToIndex:range1.location];
                    label.text = nextstr;
                }else{
                    NSRange range = [string rangeOfString:@"note =\""];
                    if (range.location != NSNotFound) {
                        NSString *nextstr = [string substringFromIndex:range.location+range.length];
                        NSRange range1 = [nextstr rangeOfString:@"\""];
                        nextstr = [nextstr substringToIndex:range1.location];
                        label.text = nextstr;
                    }
                }
                savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            }
        }
    }
    
    
    if (fasda) {
        NSDateFormatter *formatter	=  [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyyMMddHHmm"];
        NSString *strCurTime = [formatter stringFromDate:[NSDate date]];
        
        NSString *name = [NSString stringWithFormat:@"%@_%@.txt", strCurTime, version_];
        
        if (noti.object) {
            NSString *string = noti.object;
            
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(135, 0, SCREEN_WIDTH-135-10, 0)];
            [self.view addSubview:label];
            
            UILabel *labelxx = [[UILabel alloc] initWithFrame:CGRectMake(135, 0, SCREEN_WIDTH-135-10, 0)];
            [self.view addSubview:labelxx];
            
            //<?xml version="1.0" encoding="utf-8"?><wifi_cmd cmd="3" /><app_data data0="0400010000" data1="087632353031313336" data2="064552524F5231" data3="04999A42B1" data4="04999A42B1" data5="020058" data6="0418744179" /><app_management unit="1" department="2" head="3" item="4" serinum="5" note ="6" />
            
            //流量
            labelxx.text = @"瞬时流量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data0=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
                
                range = [string rangeOfString:@"data10=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                //            label.text = [NSString stringWithFormat:@"%@ (%@)", label.text,  [RecInfo getString:nextstr]];
                NSString *danwei = [RecInfo getString:nextstr];
                
                if ([danwei hasSuffix:@"s"]) {
                    
                    [self setLabel:label string:nextstr];
                    
                    label.text = [NSString stringWithFormat:@"%@%@", label.text,  danwei];//瞬时流量
                }else if ([danwei hasSuffix:@"m"]) {
                    
                    range = [string rangeOfString:@"data11=\""];
                    nextstr = [string substringFromIndex:range.location+range.length];
                    range1 = [nextstr rangeOfString:@"\""];
                    nextstr = [nextstr substringToIndex:range1.location];
                    [self setLabel:label string:nextstr];
                    
                    label.text = [NSString stringWithFormat:@"%@%@", label.text,  danwei];//瞬时流量
                }else{
                    
                    range = [string rangeOfString:@"data12=\""];
                    nextstr = [string substringFromIndex:range.location+range.length];
                    range1 = [nextstr rangeOfString:@"\""];
                    nextstr = [nextstr substringToIndex:range1.location];
                    
                    [self setLabel:label string:nextstr];
                    
                    label.text = [NSString stringWithFormat:@"%@%@", label.text, danwei];//瞬时流量
                }
            }
            
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            labelxx.text = @"流速:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data1=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
                
                
                range = [string rangeOfString:@"data8=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
                
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            labelxx.text = @"正累积量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data2=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                
                [self setnIntLabel:label string:nextstr];
                
                range = [string rangeOfString:@"data5=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@×%@", label.text, [RecInfo getInt:nextstr]];
                
                range = [string rangeOfString:@"data9=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
                
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            labelxx.text = @"负累积量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data3=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                [self setnIntLabel:label string:nextstr];
                
                
                range = [string rangeOfString:@"data6=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@×%@", label.text, [RecInfo getInt:nextstr]];
                
                range = [string rangeOfString:@"data9=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
                
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            labelxx.text = @"净累积量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data4=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                [self setnIntLabel:label string:nextstr];
                
                range = [string rangeOfString:@"data7=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@×%@", label.text, [RecInfo getInt:nextstr]];
                
                range = [string rangeOfString:@"data9=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
                
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            ///////////////////////////////能量
            labelxx.text = @"进水温度:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data13=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
                savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            }
            
            labelxx.text = @"出水温度:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data14=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"瞬时能量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data15=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
                
                range = [string rangeOfString:@"data22=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"热量累积量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data16=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                
                [self setnIntLabel:label string:nextstr];
                
                range = [string rangeOfString:@"data19=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@×%@", label.text, [RecInfo getInt:nextstr]];
                
                range = [string rangeOfString:@"data23=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
//                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
                label.text = [NSString stringWithFormat:@"%@", label.text];
                
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"冷量累积量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data17=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setnIntLabel:label string:nextstr];
                
                range = [string rangeOfString:@"data20=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@×%@", label.text, [RecInfo getInt:nextstr]];
                
                range = [string rangeOfString:@"data23=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
//                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
                label.text = [NSString stringWithFormat:@"%@", label.text];
                
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"能量累积量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data18=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setnIntLabel:label string:nextstr];
                
                range = [string rangeOfString:@"data21=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = [NSString stringWithFormat:@"%@×%@", label.text, [RecInfo getInt:nextstr]];
                
                range = [string rangeOfString:@"data23=\""];
                nextstr = [string substringFromIndex:range.location+range.length];
                range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
//                label.text = [NSString stringWithFormat:@"%@%@", label.text,  [RecInfo getString:nextstr]];
                label.text = [NSString stringWithFormat:@"%@", label.text];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            ///////////////////////////////产品
            
            labelxx.text = @"产品地址:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data24=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                
                [self setnIntLabel:label string:nextstr];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"序列号:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data25=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                label.text = [RecInfo getString:label.text];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"错误代码:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data26=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                label.text = [RecInfo getString:label.text];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"上游信号:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data27=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"下游信号:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data28=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"信号质量:";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data29=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setnIntLabel:label string:nextstr];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@\n", labelxx.text, label.text];
            
            
            labelxx.text = @"输出(4-20mA):";
            if ([string length] > 0) {
                NSRange range = [string rangeOfString:@"data30=\""];
                NSString *nextstr = [string substringFromIndex:range.location+range.length];
                NSRange range1 = [nextstr rangeOfString:@"\""];
                nextstr = [nextstr substringToIndex:range1.location];
                label.text = nextstr;
                
                [self setLabel:label string:nextstr];
            }
            savetext = [savetext stringByAppendingFormat:@"%@%@mA\n", labelxx.text, label.text];
            
            
            [savetext writeToFile:[DataManager storePathWithFileName:name] atomically:YES encoding:NSUTF8StringEncoding error:nil];
        }
        
        //INFO 03 08 7632353031313336 04 06 513F9E041933 0000
        
        //savetext
        
        NSLog(@"DeviceInfoViewController  %@", version_);
        NSString *MSG = [NSString stringWithFormat:@"文件成功导出,文件保存位置: %@", [DataManager storePathWithFileName:name]];
        UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:MSG delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertview show];
        
        
    }
    fasda = NO;
}
-(void)back{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self initTabview];
    tabview.delegate = self;
    tabview.dataSource = self;
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 64;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"TableView1Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.textLabel.textAlignment = UITextAlignmentCenter;
    cell.textLabel.font = [UIFont systemFontOfSize:17];
    cell.textLabel.textColor = [UIColor blackColor];
    
    if (indexPath.row == 0) {
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.font = [UIFont boldSystemFontOfSize:20];
        cell.textLabel.text = @"仪表";
    }else if(indexPath.row == 1){
        cell.textLabel.text = @"管理信息";
    }else if(indexPath.row == 2){
        cell.textLabel.text = @"流量信息";
    }else if(indexPath.row == 3){
        cell.textLabel.text = @"能量信息";
    }else if(indexPath.row == 4){
        cell.textLabel.text = @"产品信息";
    }else{
        cell.textLabel.text = @"导出数据";
    }
    
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        
    }else if (indexPath.row == 5) {
        
        UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"是否导出？" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
        alertview.tag = 22;
        [alertview show];
    }else {
        DevDetailViewController *newDeviceView = [[DevDetailViewController alloc] init];
        newDeviceView.type = indexPath.row;
        [self.navigationController pushViewController:newDeviceView animated:YES];
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (alertView.tag == 22) {
        if (buttonIndex == 0) {
            fasda = YES;
            //            [[PokerControlClient share] startCmd:@"3" code:@"<app_data addr0=\"00430002\"  addr1=\"00450004\" addr2=\"001d0003\" addr3=\"00160002\" addr4=\"00180002\" addr5=\"001a0001\" addr6=\"001b0002\" />"];
            
//            [[PokerControlClient share] startCmd:@"1" code:nil];
            
            
            [[PokerControlClient share] startCmd:@"3" code:@"<app_data addr0=\"00000002\"  addr1=\"00060002\" addr2=\"00080002\" addr3=\"000b0002\" addr4=\"000e0002\" addr5=\"000a0001\" addr6=\"000d0001\" addr7=\"00100001\" addr8=\"003b0002\" addr9=\"003f0001\"  addr10=\"003d0002\" addr11=\"00020002\" addr12=\"00040002\" addr13=\"00490002\"  addr14=\"004b0002\" addr15=\"00140002\" addr16=\"004d0002\" addr17=\"00500002\" addr18=\"00110002\" addr19=\"004f0001\" addr20=\"00520001\" addr21=\"00130001\" addr22=\"00400002\"  addr23=\"00420001\" addr24=\"00430002\"  addr25=\"00450004\" addr26=\"001d0003\" addr27=\"00160002\" addr28=\"00180002\" addr29=\"001a0001\" addr30=\"001b0002\" />"];//流量，能量10，产品100
        }
    }
}

/*
 单位:1
 部门:2
 负责人:3
 位号:4
 序列号:5
 备注:6
 瞬时流量:4104.32l/m
 流速:2.30m/s
 正累积量:100600x0.001m3
 负累积量:50500x0.001m3
 净累积量:50100x0.001m3
 进水温度:30.30
 出水温度:20.20
 瞬时能量:19.90GJ/h
 热量累积量:200200x0.001
 冷量累积量:120100x0.001
 能量累积量:80100x0.001
 产品地址:88
 序列号:v1234567
 错误代码:I
 上游信号:80.00
 下游信号:80.00
 信号质量:90
 输出(4-20mA):4.27mA
 */


@end




